package com.ruoyi.merchant.controller;

import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.merchant.domain.BaseDeviceExec;
import com.ruoyi.merchant.service.IBaseDeviceExecService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 设备设置参数记录Controller
 * 
 * @author xin.jucheng
 * @date 2024-03-28
 */
@RestController
@RequestMapping("/system")
public class BaseDeviceExecController extends BaseController
{
    @Autowired
    private IBaseDeviceExecService baseDeviceExecService;

    /**
     * 查询设备设置参数记录列表
     */
    @RequiresPermissions("system:system:list")
    @GetMapping("/list")
    public TableDataInfo list(BaseDeviceExec baseDeviceExec)
    {
        startPage();
        List<BaseDeviceExec> list = baseDeviceExecService.selectBaseDeviceExecList(baseDeviceExec);
        return getDataTable(list);
    }

    /**
     * 导出设备设置参数记录列表
     */
    @RequiresPermissions("system:system:export")
    @Log(title = "设备设置参数记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BaseDeviceExec baseDeviceExec)
    {
        List<BaseDeviceExec> list = baseDeviceExecService.selectBaseDeviceExecList(baseDeviceExec);
        ExcelUtil<BaseDeviceExec> util = new ExcelUtil<BaseDeviceExec>(BaseDeviceExec.class);
        util.exportExcel(response, list, "设备设置参数记录数据");
    }

    /**
     * 获取设备设置参数记录详细信息
     */
    @RequiresPermissions("system:system:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(baseDeviceExecService.selectBaseDeviceExecById(id));
    }

    /**
     * 新增设备设置参数记录
     */
    @RequiresPermissions("system:system:add")
    @Log(title = "设备设置参数记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BaseDeviceExec baseDeviceExec)
    {
        return toAjax(baseDeviceExecService.insertBaseDeviceExec(baseDeviceExec));
    }

    /**
     * 修改设备设置参数记录
     */
    @RequiresPermissions("system:system:edit")
    @Log(title = "设备设置参数记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BaseDeviceExec baseDeviceExec)
    {
        return toAjax(baseDeviceExecService.updateBaseDeviceExec(baseDeviceExec));
    }

    /**
     * 删除设备设置参数记录
     */
    @RequiresPermissions("system:system:remove")
    @Log(title = "设备设置参数记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(baseDeviceExecService.deleteBaseDeviceExecByIds(ids));
    }
}
